package com.letoken.platform.repo.admin.manager;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.letoken.platform.repo.admin.dao.AppVersionMapper;
import com.letoken.platform.repo.admin.po.AppVersion;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * @author wyl
 * @date 2023/3/3 15:03
 * @Version 1.0
 */
@Log4j2
@Repository
public class AppVersionManager {
    @Autowired
    private AppVersionMapper appVersionMapper;

    /**
     * 判断版本是否重复
     */
    public boolean versionIsRepeat(Integer client,String currentVersion){
        LambdaQueryWrapper<AppVersion> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(AppVersion::getClient,client)
                        .eq(AppVersion::getCurrentVersion,currentVersion);
        Integer count = appVersionMapper.selectCount(queryWrapper);
        return count > 0;
    }
}
